package sealte.wdgf.model.system;

import java.io.Serializable;

import org.apache.commons.dbcp.BasicDataSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class DataSourceObject implements Serializable{

	private static final long serialVersionUID = 7051156814314782910L;
	private String driverClassName;
	private String url;
	private String userName;
	private String password;
	private int maxActive;
	private int minIdle;
	private int initialSize;
	static Logger logger = LoggerFactory.getLogger(DataSourceObject.class);
	
	public void setDriverClassName(String driverClassName) {
		this.driverClassName = driverClassName;
	}
	
	public void setUrl(String url) {
		this.url = url;
	}
	
	public void setUserName(String userName) {
		this.userName = userName;
	}
	
	public void setPassword(String password) {
		this.password = password;
	}
	
	public void setMaxActive(int maxActive) {
		this.maxActive = maxActive;
	}
	
	public void setMinIdle(int minIdle) {
		this.minIdle = minIdle;
	}
	
	public void setInitialSize(int initialSize) {
		this.initialSize = initialSize;
	}
	
	public BasicDataSource getDataSource(){
		BasicDataSource ds = new BasicDataSource();
		try {
			ds.setDriverClassName(this.driverClassName);
		} catch (Exception e) {
			logger.error("加载数据库驱动出错！原因："+e.getMessage());
		}
		ds.setUrl(this.url);
		ds.setUsername(this.userName);
		ds.setPassword(this.password);
		ds.setMaxActive(this.maxActive);
		ds.setMinIdle(this.minIdle);
		ds.setInitialSize(this.initialSize);
		return ds;
	}
	
}
